#include <bits/stdc++.h>
using namespace std;
#define lson i<<1
#define rson i<<1|1
#define _clr(x,a) memset(x,a,sizeof(x));
typedef long long ll;
const int N=1e5+50;
const int M=2e5+50;
int n,m,u,v,x,y;
ll a,b;
ll arr[N],val[N];
struct Edge{
    int v,next;
}edge[M];
int cnt,head[N];
void addEdge(int u,int v){
    edge[cnt]=Edge{v,head[u]};
    head[u]=cnt++;
    edge[cnt]=Edge{u,head[v]};
    head[v]=cnt++;
}
int siz[N],fa[N],dep[N],son[N];
void dfs1(int u,int f,int d){
    fa[u]=f;
    dep[u]=d;
    siz[u]=1;
    for(int i=head[u];i!=-1;i=edge[i].next){
        int v=edge[i].v;
        if(v==f){
            continue;
        }
        dfs1(v,u,d+1);
        siz[u]+=siz[v];
        if(siz[v]>siz[son[u]]){
            son[u]=v;
        }
    }
}
int top[N],id[N],rk[N],sz;
void dfs2(int u,int t){
    id[u]=++sz;
    rk[sz]=u;
    top[u]=t;
    if(!son[u]){
        return;
    }
    dfs2(son[u],t);
    for(int i=head[u];i!=-1;i=edge[i].next){
        int v=edge[i].v;
        if(v!=fa[u] && v!=son[u]){
            dfs2(v,v);
        }
    }
}
struct Node{
    int l,r;
    ll mx,mn,sum;
}tree[N<<2];
void init(){
    cnt=0;
    sz=0;
    _clr(head,-1);
    _clr(arr,0);
    _clr(val,0);
    _clr(edge,0);
    _clr(siz,0);
    _clr(fa,0);
    _clr(dep,0);
    _clr(son,0);
    _clr(top,0);
    _clr(id,0);
    _clr(tree,0);
}
void pushup(int i){
    tree[i].sum=tree[lson].sum+tree[rson].sum;
    tree[i].mx=max(tree[lson].mx,tree[rson].mx);
    tree[i].mn=min(tree[lson].mn,tree[rson].mn);
}
void build(int i,int l,int r){
    tree[i].l=l;
    tree[i].r=r;
    if(l==r){
        tree[i].sum=tree[i].mx=tree[i].mn=val[rk[l]];
        return;
    }
    int mid=(l+r)>>1;
    build(lson,l,mid);
    build(rson,mid+1,r);
    pushup(i);
}
ll query(int i,int x,int y,ll a,ll b){
    int l=tree[i].l,r=tree[i].r;
    int mid=(l+r)>>1;
    if(x<=l && r<=y){
        if(tree[i].mn>b || tree[i].mx<a){
            return 0;
        }
        if(tree[i].mn>=a && tree[i].mx<=b){
            return tree[i].sum;
        }
        return query(lson,x,mid,a,b)+query(rson,mid+1,y,a,b);
    }
    if(y<=mid){
        return query(lson,x,y,a,b);
    }else if(x>mid){
        return query(rson,x,y,a,b);
    }else{
        return query(lson,x,mid,a,b)+query(rson,mid+1,y,a,b);
    }
}
ll solve(int x,int y,ll a,ll b){
	ll sum=0;
    while(top[x]!=top[y]){
        if(dep[top[x]]<dep[top[y]]){
            swap(x,y);
        }     
		sum+=query(1,id[top[x]],id[x],a,b);
		x=fa[top[x]];
	}
    if(dep[x]>dep[y]){
        swap(x,y);
    }
	sum+=query(1,id[x],id[y],a,b);
    return sum;
}
int main(void){
    while(~scanf("%d%d",&n,&m)){
        init();
        for(int i=1;i<=n;i++){
            scanf("%lld",&val[i]);
        }
        for(int i=0;i<n-1;i++){
            scanf("%d%d",&u,&v);
            addEdge(u,v);
        }
        dfs1(1,0,1);
        dfs2(1,1);
        build(1,1,n);
        vector<ll> ans;
        while(m--){
            scanf("%d%d%lld%lld",&x,&y,&a,&b);
            ans.push_back(solve(x,y,a,b));
        }
        int l=ans.size();
        for(int i=0;i<l;i++){
            printf("%lld",ans[i]);
            if(i!=l-1){
                printf(" ");
            }
        }
        printf("\n");
    }
    return 0;
}